﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

namespace ProjectStudy.App_Code
{
    public class BasePageCheckRight:BasePage
    {

        //public override bool IsCheckRight()
        //{ 
        //  return true;
        //}

        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);
                if (!CheckPageRight())
                {
                    Response.Write("你没有权限访问该页面");
                    Response.End();
                }
        }
       
        protected bool CheckPageRight()
        {
            string PageId = Request["PageId"].ConvertObjToStr();
            string sql2 = "select 1 from PageACL where PageId=@pageid and PageRightClass<=@class";
            SqlParameter[] ps2 = { 
                                new SqlParameter("@pageid",PageId),
                                new SqlParameter("@class",SysSession.classRight)
                                };
            DataTable dt2 = DBAccess.ExecuteDataTable(sql2,ps2);
            if (dt2.Rows.Count > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}